package com.hzsai.entity;

import lombok.Data;

import java.io.Serializable;

/**
 * @author: hzsai
 * @date : 2020/3/19/ 1:13
 **/
@Data
public class ResponseEntity implements Serializable {

    private static final long serialVersionUID = 7173264927439L;

    private int code;
    private String message;
    private Object data;

    ResponseEntity(int code, String message, Object obj) {
        this.code = code;
        this.message = message;
        this.data = obj;
    }

    public static ResponseEntity success(int code, String message, Object obj) {
        return new ResponseEntity(code, message, obj);
    }

    public static ResponseEntity fail(int code, String message, Object obj) {
        return new ResponseEntity(code, message, obj);
    }

    public static ResponseEntity re(HttpStatus status) {
        return new ResponseEntity(status.getStatus(), status.getDescription(), null);
    }
}
